﻿using System;
using System.Collections.Generic;
using System.Linq;

using System.Web.Mvc;
using Prodma.DataAccess.Database;
using Prodma.DataAccess.Models;
using Prodma.DataAccess.Helper.Enumerators;

namespace Prodma.DataAccess.DataService.ListService
{
    public static class MenuAdminList
    {

        private static DataContext context = new DataContext();

        public static SelectList GetParentItems()
        {
            DataContext context = new DataContext();
            using (context)
            {
                var list = (from menu in context.tb_MenuAdmin
                            where menu.ParentId == 0
                            select menu);
                SelectList selectList = new SelectList(list.ToDictionary(x => x.Id, z => z.Name), "Key", "Value");

                return selectList;
            }
        }
        public static SelectList GetSubItems(int parentId)
        {
            DataContext context = new DataContext();
            using (context)
            {
                var list = (from menu in context.tb_MenuAdmin
                            where menu.ParentId == parentId
                            select menu);
                SelectList selectList = new SelectList(list.ToDictionary(x => x.Id, z => z.Name), "Key", "Value");

                return selectList;
            }

        }
    }
}